<?php

namespace app\common\core;

use think\exception\HttpResponseException;

class RedirectException
{
    protected static $instance;
    public static function instance()
    {
        if(is_null(self::$instance)){
            self::$instance = new static();
        }
        return self::$instance;
    }
    public function redirect($url, $params = [], $code = 302, $with = [])
    {
        if (is_int($params)) {
            $code = $params;
        }
        $response = \redirect($url);
        $response->code($code)->with($with);

        throw new HttpResponseException($response);
    }
}